package vn.cent.game.cardtype.beans;

import java.util.List;
import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap;

import vn.cent.game.cardtype.main.CardTypeGameExtension;
import vn.cent.game.cardtype.utils.GameState;
import vn.cent.game.cardtype.utils.PlayerState;

import com.smartfoxserver.v2.entities.Room;
import com.smartfoxserver.v2.entities.User;

public class GameBean {
	
	protected Room roomID;
	
	protected int host;
	
	// Look like we should remove this propertie
	protected List<Integer> guestList;
	
	protected int spector;
	
	protected boolean isStarted;
	
	// List current player
	protected ConcurrentHashMap<Integer, IUser> players;
	
	protected ConcurrentHashMap<Integer, IUser> spectors;
	
	protected Timer timer;
	
	protected int JoinPriority;
	
	private int MAX_USER = 10;
	
	
	protected GameState currentState = GameState.None;
	
	public int getMAX_USER() {
		return MAX_USER;
	}

	public void setMAX_USER(int MAX_USER) {
		MAX_USER = MAX_USER;
	}

	public GameState getCurrentState() {
		return currentState;
	}

	public void setCurrentState(GameState currentState) {
		this.currentState = currentState;
	}

	public void setGuestList(List<Integer> guestList) {
		this.guestList = guestList;
	}

	public GameBean(Room room, int host)
	{
		
		this.roomID = room;
		this.host = host;
		this.spector = -1;
		this.isStarted = false;
		
		players = new ConcurrentHashMap<Integer, IUser>();
		spectors = new ConcurrentHashMap<Integer, IUser>();	
	}

	public Room getRoomID() {
		return roomID;
	}

	public void setRoomID(Room roomID) {
		this.roomID = roomID;
	}

	public int getHost() {
		return host;
	}

	public void setHost(int host) {
		this.host = host;
	}

	public List<Integer> getGuestList() {
		return guestList;
	}

	public void setGuest(int guestID) {
		guestList.add(guestID);
	}

	public int getSpector() {
		return spector;
	}

	public void setSpector(int spector) {
		this.spector = spector;
	}

	public boolean isStarted() {
		return isStarted;
	}

	public void setStarted(boolean isStarted) {
		this.isStarted = isStarted;
	}

	public ConcurrentHashMap<Integer, IUser> getPlayers() {
		return players;
	}

	public void setPlayers(ConcurrentHashMap<Integer, IUser> players) {
		this.players = players;
	}

	public ConcurrentHashMap<Integer, IUser> getSpectors() {
		return spectors;
	}

	public void setSpectors(ConcurrentHashMap<Integer, IUser> spectors) {
		this.spectors = spectors;
	}

	public Timer getTimer() {
		return timer;
	}

	public void setTimer(Timer timer) {
		this.timer = timer;
	}
	
	public int getJoinPriority() {
		return JoinPriority;
	}

	public void setJoinPriority(int joinPriority) {
		JoinPriority = joinPriority;
	}

	public void StartGame(CardTypeGameExtension extension, List<IUser> recippients)
	{
		
	}
	
	protected void SetCurrentState(GameState newState)
	{
		currentState = newState;
	}
	
	protected GameState GetCurrentState()
	{
		return currentState;
	}
	
	public boolean isAvaiableToJoin()
	{
		if (players.size() < MAX_USER)
			return true;
		return false;
	}
}
